
<?php include_once 'common/header.php';  ?>
<!-- admin_main -->
<div class="admin_main">
	<!-- Admin_top end -->
	<?php include_once 'common/shop_left.php';  ?>
	<!-- Admin_Left End -->
	<div class="admin_right">
		<div class="admin_right_title">
			<strong>商城管理</strong> &gt;&gt;  商品详情
		</div>
		
		<div class="admin_right_info">
			<iframe name="iframe" id="iframe" style="display:none;"></iframe>
			<form action="/ychadmin/shop/toset" enctype="multipart/form-data" method="post" target="iframe">
			
			<input type="hidden" name="id" value="<?php echo isset($info['id']) ? $info['id']: '';?>"/>
			<ul>
			<li>商品名称：<input type="text" name="pname" value="<?php echo isset($info['pname']) ? $info['pname']: '';?>" /></li>
			<li>商品类型：
                <select  id="ptype" name="ptype">
                    <option value="0">顶级分类</option>
                    <?php foreach ($site_array as $val) { ?>
                        <option value="<?php echo $val['id'] ?>" <?php if ($val['id'] == $info['ptype']) {
                            echo 'selected';
                        } ?>><?php echo $val['title'] ?></option>
                        <?php
                        if (isset($val['category_list']) && is_array($val['category_list']) && count($val['category_list']) > 0) {
                            foreach ($val['category_list'] as $v) {
                                ?>
                                <option value="<?php echo $v['id'] ?>" <?php if ($v['id'] == $info['ptype']) {
                                    echo 'selected';
                                } ?>>--<?php echo $v['title'] ?></option>

                                <?php
                                if (isset($v['third_list']) && is_array($v['third_list']) && count($v['third_list']) > 0) {
                                    foreach ($v['third_list'] as $third) {
                                        ?>
                                        <option value="<?php echo $third['id'] ?>" <?php if ($third['id'] == $info['ptype']) {
                                            echo 'selected';
                                        } ?>>----<?php echo $third['title'] ?></option>
                                        <?php }
                                } ?>
                     <?php }
                        } ?>
                    <?php } ?>
                </select>
			</li>
			<li id="img">
                <div class="mod">
                    <input type="hidden" id="att_id" name="att_id" />
                    <span id="logoimgTip"><a  href="javascript:;" onclick="add_att();" class="addtr">添加商品图片</a></span>
                    <ul id="guarantee_att">
                        <?php
                        if ($att_list) {
                            foreach ($att_list as $av) {
                                ?>
                                <li id="att_litpic_<?php echo $av['id'] ?>"><a target="_blank" href="/<?php echo $av['pic'] ?>"><img src="/<?php echo $av['pic'] ?>" width="60" height="60"  /></a>
                                    <h5><?php echo $av['name'] ?></h5>
                                    <span><a href="javascript:attremove(<?php echo $av['id'] ?>);">删除</a></span>
                                </li>
                            <?php
                            }
                        }
                        ?>

                    </ul>
                </div>

<!--				<input type="file" class="input_border" size="20" name="pimg" /><br />-->
<!--				--><?php //if (isset($info['pimg']) && $info['pimg']){?>
<!--				    <img src="--><?php //echo $info['pimg'];?><!--" alt="" style="width:90px;height:90px;"/>-->
<!--				--><?php //}?>
			</li>
			<li>是否只允许VIP兑换：
				<input type="radio" name="pvip" value="0" <?php if(!isset($info['pvip']) || $info['pvip']==0) echo "checked='checked'"; ?>/>否  
				<input type="radio" name="pvip" value="1" <?php if(isset($info['pvip']) && $info['pvip']==1) echo "checked='checked'"; ?>/>是
			</li>
			<li>市场价格：<input type="text" name="pmoney" value="<?php echo isset($info['pmoney']) ? $info['pmoney']: '';?>" /> </li>
			<li>积分价格：<input type="text" name="pcredit" value="<?php echo isset($info['pcredit']) ? $info['pcredit']: '';?>" /> </li>
			<li>VIP价格：<input type="text" name="pvipcredit" value="<?php echo isset($info['pvipcredit']) ? $info['pvipcredit']: '';?>" /> </li>
			<li>商品状态：
				<input type="radio" name="pstatus" value="0" <?php if(!isset($info['pstatus']) || $info['pstatus']==0) echo "checked='checked'"; ?>/>下架  
				<input type="radio" name="pstatus" value="1" <?php if(isset($info['pstatus']) && $info['pstatus']==1) echo "checked='checked'"; ?>/>上架
			</li>
			<li>是否推荐：
				<input type="radio" name="ptui" value="0" <?php if(!isset($info['ptui']) || $info['ptui']==0) echo "checked='checked'"; ?>/>否  
				<input type="radio" name="ptui" value="1" <?php if(isset($info['ptui']) && $info['ptui']==1) echo "checked='checked'"; ?>/>是
			</li>
			<!--<li>是否参团：
				<input type="radio" name="ptuan" value="0" <?php if(!isset($info['ptuan']) || $info['ptuan']==0) echo "checked='checked'"; ?>/>否  
				<input type="radio" name="ptuan" value="1" <?php if(isset($info['ptuan']) && $info['ptuan']==1) echo "checked='checked'"; ?>/>是
			</li>
			--><li>折扣率：<input type="text" name="prate" style="width:50px;" value="<?php echo isset($info['prate']) ? $info['prate']: 1;?>"/>[0.8为8折;1为无折扣] </li>
			<li>是否热门：
				<input type="radio" name="phot" value="0" <?php if(!isset($info['phot']) || $info['phot']==0) echo "checked='checked'"; ?>/>否  
				<input type="radio" name="phot" value="1" <?php if(isset($info['phot']) && $info['phot']==1) echo "checked='checked'"; ?>/>是
			</li>
			<li>已兑换：<input type="text" name="pconvert" style="width:50px;" value="<?php echo isset($info['pconvert']) ? $info['pconvert']: 0;?>"/>件 </li>
			<!--<li>秒杀抢购：
				<input type="radio" name="prob" value="0" <?php if(!isset($info['prob']) || $info['prob']==0) echo "checked='checked'"; ?>/>否  
				<input type="radio" name="prob" value="1" <?php if(isset($info['prob']) && $info['prob']==1) echo "checked='checked'"; ?>/>是
			</li>
			<li>开抢时间：<input type="text" name="probstart" style="width:150px;" value="<?php echo isset($info['probstart']) && $info['probstart'] ? date('Y-m-d H:i:s',$info['probstart']): '';?>" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/> </li>-->
			<li>剩余数：<input type="text" name="psurp" style="width:50px;" value="<?php echo isset($info['psurp']) ? $info['psurp']: 0;?>"/>件 </li>
			<li>详情描述：
				<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
    			<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.js"></script>
    			<script type="text/javascript" charset="utf-8">
			          var editor = new baidu.editor.ui.Editor();
			          editor.render('pdesc');  //editor为编辑器容器的id
			      </script>
				<textarea name="pdesc" id="pdesc" style="width:800px">
				<?php echo isset($info['pdesc']) ? $info['pdesc']:'';?>
				</textarea>
			</li>
			
			<li><input type="submit" value="确认<?php echo isset($info['id']) ? '修改':'添加';?>" /></li>
			
			
			</ul>
			</form>

		</div>
			
	</div>
<!-- Admin_Right End -->
</div>

<div class="user_list_con" id="grarantee_dialog" style="display:none;">
    <div id="grarantee_dialog_msg" style="text-align:center;color:red">&nbsp;</div>
    <iframe name="iframe" id="iframe" style="display:none;"></iframe>
    <form id="upload_form"  action=""  enctype="multipart/form-data" method="post" target="iframe">

        <div class="payonline_form">

            <dl class="online_dl" style="height:20px;">
                <dt>名称：</dt>
                <dd>
                    <input type="text" name="name">
                </dd>
            </dl>
            <br />
            <dl class="online_dl" style="height:20px;">
                <dt>上传资料：</dt>
                <dd>
                    <input type="file" name="pic" />
                </dd>
            </dl>
        </div>
    </form>
</div>

<script type="text/javascript">
    $('#img').find('input:last').live('click',function(){
        var _input = $('<input type="file" class="input_border" size="20" name="pimg" style="margin-left: 70px"/><br />');
        $('#img').append(_input);
    });

    function add_att() {
        $("#grarantee_dialog").dialog({
            width: 600,
            height: 300,
            modal: false, //蒙层（弹出会影响页面大小）
            title: '添加证明资料',
            buttons: {"提交": function () {
                form_submit();
            }, "关闭": function () {
                $(this).dialog("close");
            }}
        });
    }

    var att_arr = [];//定义一个数组
    function form_submit() {
        var options = {
            url: '/ychadmin/shop/doupload',
            clearForm: true,
            resetForm: true,
            beforeSubmit: checkForm,
            dataType: "json",
            type: "post",
            contentType: "multipart/form-data",
            success: function (ret) {
                if (ret.url == 'error') {
                    alert(ret.msg);
                } else {
                    $("#grarantee_dialog").dialog("close");
                    $("#guarantee_att").append('<li id="att_litpic_' + ret.msg.id + '"><a target="_blank" href="/' + ret.msg.pic + '"><img src="/' + ret.msg.pic + '" width="60" height="60"  /></a><h5>' + ret.msg.name + '</h5><span><a href="javascript:attremove(' + ret.msg.id + ');">删除</a></span></li>');
                    att_arr.push(ret.msg.id);
                    $("#att_id").val(att_arr);
                }

            }
        };

        $("#upload_form").ajaxSubmit(options);
        return false;
    }

    function checkForm() {
        return true;
    }

    function attremove(id) {
        $.ajax({
            type: "get",
            url: '/ychadmin/shop/del_att/' + id,
            success: function (ret) {
                $("#att_litpic_" + id).remove();
            },
            dataType: "json"
        });
    }
</script>

<!-- admin_main end -->
</body>
</html>
